//
//  ViewController.swift
//  SwiftDemo
//
//  Created by apple on 17/3/2.
//  Copyright © 2017年 AllenZyq. All rights reserved.
//

import UIKit
//import ZyqObjc.swift
//import PhotosUI




class Person {
    var residence: Residence?
}

class Residence {
    var numberOfRooms = 1
}


var age = 10;

class VideoClass {
    var interlaced = false
    var frameRate = 0.0
    var  name : String?
}

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let Zyq = Person ()
        Zyq.residence = Residence()
    
        let roomCount = Zyq.residence? .numberOfRooms;
        
        
//        let view = UIviewYP()
//        if view is UIView {
//            print("111");
//        }
        print(roomCount!);
        
//        let viewDeo1 = VideoClass();
//        let viewDeo2  = viewDeo1;
////        viewDeo1.name = "zyq";
//        
//        if viewDeo2 === viewDeo1 {
////            print(viewDeo1.name!);
////            print("zyq");
//        }
////        
        let zyq1 = ZyqObjc();
//        ZyqObjc.countTo100();
        zyq1.count = 0;
//
////        zyq1.increment();
////        zyq1.increment();
////        zyq1.count = 100;
////        zyq1.incrementBy(amount: 10);
////        zyq1.resetCount();
//        
//        print("zyq  ",age);
//        ageUp();
//        print("zyq  ",age);
//        ageUp();
//
////        age = 100;
//        ageUp();
//
//        print("zyq  ",age);

        
        
        
    //数组练习
#if DEBUG
        
        var shopList:[String] = ["ahllen","iverson"];
        let sada = shopList.isEmpty;
        shopList.append("111");
        print(shopList);
        print(sada);
        
    //字典 dic
        var sportsDic:Dictionary = ["basketball":"nba","football":"NFL","pingpang":"china"];
        print(sportsDic); //打印出来的结果 ["football": "NFL", "basketball": "nba", "pingpang": "china"]
                      //下行已经解决  //字典是否按照无需来排列的 ？ why？ 是否每次都不一样。 还没找到for循环的api 来循环打印。
//        注意： Swift 的字典类型是无序集合类型。其中字典键，值，键值对在遍历的时候会重新排列，而且其中顺序是不固定的。
        sportsDic["basketball"] = "NBA";
        print(sportsDic);
//        for name in sportsDic.values {
//            print(name);
//        }
        for (name1, name2) in sportsDic {
            print(name1 ,name2);
        }
//        var let 
        var myname :String = "11";
        let age : int_fast32_t = 22;
        
        myname.append("222");
        print(myname);
        print(age + 2);//24
        
        let doubleAge = Double (age);
        print(doubleAge); //22.0
        //元组
        let http404Error = (404,"not font");
//        print(http404Error);
        let (stateCode, statusMessage) = http404Error;
        print(stateCode);//404
        print(statusMessage);//not font
        
        let (justStateCode,_) = http404Error; //不想要的字段可以直接用_不理睬
        print(justStateCode);//404
        
        print(http404Error.0); //404
        print(http404Error.1); // not font
        
        
//        你可以在定义元组的时候给单个元素命名：  就像字典一样 key value。
        let yaopaiTEC = (mmpBack:1.1,description:"sbht");
        print(yaopaiTEC.mmpBack);
        print(yaopaiTEC.description);

        var possibleNumber = "134";
        var converterNumber0 = Int(possibleNumber);
        print(converterNumber0! + 22);
//        注意：使用!来获取一个不存在的可选值会导致运行时错误。使用!来强制解析值之前，一定要确定可选包含一个非nil的值。
        
        print(possibleNumber);
        
        possibleNumber = "aaa";
         converterNumber0 = Int(possibleNumber);
        print(converterNumber0 ?? "wozuishuai"); //?? 如果是nil 就写你给的defalut
        
        if (converterNumber0 != nil) {
            print("肯定有",converterNumber0!)
        }else {
            print(converterNumber0 ?? "dadadadada");
        }
        
        #endif
        
        let threeTimesTable = TimesTable(multiplier: 3)//附属脚本语法

        print("zzzzz",threeTimesTable[1])
        
    }
    func ageUp() {
        age += 1;
    }
    
    
    
    
    func ageupup (count:Int, coun2:Int) -> Bool {
        return count > coun2
    }
    
    
    func aggggg (count :Int) -> (String,String,String) {
        return ("11","22","33");
    }
    
    
    struct TimesTable {
        let multiplier :Int
        subscript (indedx : Int) ->Int {
            return multiplier * indedx;
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

